package de.tuberlin.dima.dkey.nodes;

public class TextNode implements GNode{

	private static final long serialVersionUID = 1L;
	
	protected int id;
	protected String value;
	protected int graph;
	final String type = "TextNode";
	
	public TextNode(){
		throw new UnsupportedOperationException(); 
	}
	
	public TextNode(int graph, int id, String value){
		this.id = id;
		this.value = value;
		this.graph = graph;
	}
	
	public String getValue() {
		return value;
	}

	public int getId() {
		return id;
	}

	public int getGraph() {
		return graph;
	}
	
	public String getType(){
		return type;
	}
	
	public String getColour(){
		return "red";
	}
	

	public String[] getIndexValues() {
		return this.value.split(" ");
	}
	//The default is to only compare the String values
	public boolean equals(GNode toEval) {
		//return  this.value.contains(toEval.getValue());
		return equalsIgnoreCase(toEval);
	}
	
	public boolean equalsIgnoreCase(GNode toEval) {
		return  this.value.toLowerCase().contains(toEval.getValue().toLowerCase());
	}	

	
	@Override public String toString() {
		return id + ":" +value + ":" + graph;
	}
	
	/**
     * Returns the hash code value for this edge.
     *
     * @return the hash code value for this list
     */
    public int hashCode() {
        int hashCode = 1;
        
        hashCode = 31*hashCode + id;
        hashCode = 31*hashCode + value.hashCode();
        
        return hashCode;
    }
	
}
